package com.crm.service.impl.cluePoolManager;

import com.crm.common.model.Enum.StatusCodeEnum;
import com.crm.dao.mapper.cluePoolManager.CluePoolDistributionMapper;
import com.crm.dao.mapper.customMapper.cluePoolManagerCustomMapper.CluePoolDistributionCustomMapper;
import com.crm.model.entity.cluePoolManager.CluePoolDistribution;
import com.crm.model.entity.cluePoolManager.CluePoolDistributionExample;
import com.crm.model.vo.cluePoolManager.CluePoolDistributionVO;
import com.crm.service.cluePoolManager.CluePoolDistributionDbService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author yincuimei
 * @Date 2020/12/24 11:15
 */
@Service
public class CluePoolDistributionDbServiceImpl implements CluePoolDistributionDbService {

    @Autowired
    private CluePoolDistributionMapper cluePoolDistributionMapper;

    @Autowired
    private CluePoolDistributionCustomMapper cluePoolDistributionCustomMapper;

    @Override
    public Boolean addCluePoolDistribution(CluePoolDistribution cluePoolDistribution) {
        Boolean result = false;
        int num = cluePoolDistributionMapper.insertSelective(cluePoolDistribution);
        if(num>0){
            result=true;
        }
        return  result;
    }

    @Override
    public Boolean deleteCluePoolDistributionByCluePoolId(String cluePoolId) {
        CluePoolDistributionExample cluePoolDistributionExample = new CluePoolDistributionExample();
        CluePoolDistributionExample.Criteria criteria = cluePoolDistributionExample.createCriteria();
        criteria.andCluePoolIdEqualTo(cluePoolId);
        CluePoolDistribution cluePoolDistribution = new CluePoolDistribution();
        cluePoolDistribution.setDeleteStatus(Short.parseShort(String.valueOf(StatusCodeEnum.DELETE_CODE.getState())));
        return cluePoolDistributionMapper.updateByExampleSelective(cluePoolDistribution, cluePoolDistributionExample) > 0;
    }

    @Override
    public List<CluePoolDistributionVO> selectCluePoolDistributionVOList(String cluePoolId, Short deleteStatus) {
        return cluePoolDistributionCustomMapper.selectCluePoolDistributionVOList(cluePoolId,deleteStatus);
    }
}
